class Solution(object):
    def partitionDisjoint(self, nums):
        prefix = nums.copy()
        p = nums.copy()
        n = len(nums)
        for i in range(1, n):
            prefix[i] = max(prefix[i - 1], nums[i])
        for i in range(n - 2, -1, -1):
            p[i] = min(nums[i], p[i + 1])
        for i in range(n - 1):
            if prefix[i] <= p[i + 1]:
                return i + 1



data = Solution()
nums = [5, 0, 3, 8, 6]
print(data.partitionDisjoint(nums))
